<template>
  <div>
    <div class="margin-container-list">
      <!--顶部搜索 -->
      <div class="top-operate">
        <div class="pad-t-15">
          <el-input v-model="searchKeyword" @keyup.enter.native="handleSearch"  placeholder="请输入招募员名称/微客昵称/微客手机号" style="width: 300px"></el-input>
          <el-date-picker v-model="datePicker"
            type="daterange"
            unlink-panels
            range-separator="至"
            value-format="yyyy-MM-dd HH:mm:ss"
            :default-time="['00:00:00', '23:59:59']"
            start-placeholder="招募开始时间"
            end-placeholder="招募结束时间">
          </el-date-picker>
          <el-button type="primary" @click="handleSearch">查询</el-button>
        </div>
      </div>

      <!-- 内容列表 -->
      <div class="table-container">
        <el-table  ref="multipleTable" :data="dataList" v-loading="listLoading"
                   element-loading-text="加载中" style="width: 100%" >
          <el-table-column width="240px" label="招募时间" prop="createTime"></el-table-column>

          <el-table-column width="240px" label="招募员" prop="recruiterName"></el-table-column>
          <el-table-column width="240px" label="微客">
            <template slot-scope="scope">
              昵称： {{scope.row.nickname}}<br>
              手机： {{scope.row.phone}}
            </template>
          </el-table-column>
          <el-table-column width="240px" label="门店照片">
            <template slot-scope="scope">
              <template v-for="image in scope.row.memberStoreImageList">
              <img :src="image.imageUrl" width="50px">
              </template>
            </template>
          </el-table-column>
          <el-table-column width="240px" label="标签">
            <template slot-scope="scope">
                <template v-for="item in scope.row.memberLabelList">
                  <span class="pad-r-10"><el-tag>{{ item.labelName }}</el-tag></span>
                </template>
            </template>
          </el-table-column>
          <el-table-column min-width="240px" label="备注"></el-table-column>
        </el-table>
      </div>
      <!-- 列表分页 -->
      <div class="pagination">
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                       :current-page="searchListQuery.currentPage"
                       :page-sizes="[10, 20, 50, 100]" :page-size="searchListQuery.size"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="total">
        </el-pagination>
      </div>

    </div>
  </div>
</template>

<style lang="less" scoped>
  .span-member-1 {
    margin-left: 10px;
    margin-right: 10px;
  }
  .span-member-2 {
    margin-right: 10px;
  }
  .user-avatar{
    width: 46px;
    height: 46px;
    display: block;
    border-radius: 50px;
  }
</style>

<script>
  import { pagingRecruitRecord } from '@/api/user/recruiter'
  import { getDictByGroupName } from '@/api/common/common'

  export default {
    data() {
      return {
        total: null,
        listLoading: true,
        searchListQuery: {
          currentPage: 1,
          size: 10,
          enterpriseId: this.getEnterpriseId(),
          realFlag: ''
        },
        searchKeyword: '',
        dict: {},
        pagingStatus: '0',
        categoryIds: [],
        dataList: [],
        // 商品的所有分类json
        categoryData: [],
        datePicker: []
      }
    },
    // 初始化页面
    created() {
      this.initDict()
      this.initDataList()
    },
    mounted() {
    },
    methods: {
      // 更改当前页数
      handleCurrentChange(val) {
        this.searchListQuery.currentPage = val
        this.initDataList()
      },
      // 更改当前页面大小
      handleSizeChange(val) {
        this.searchListQuery.size = val
        this.initDataList()
      },
      initDict() {
        getDictByGroupName('MemberDTO').then(response => {
          this.dict = response.data
        })
      },
      initDataList() {
        if (this.datePicker && this.datePicker.length > 0) {
          this.searchListQuery['startDate'] = this.datePicker[0]
          this.searchListQuery['endDate'] = this.datePicker[1]
        }
        this.searchListQuery.keyword = this.searchKeyword
        pagingRecruitRecord(this.searchListQuery).then(response => {
          this.total = response.data.total
          this.dataList = response.data.records
          this.listLoading = false
        })
      },
      handleSearch() {
        this.searchListQuery.currentPage = 1
        this.initDataList()
      },
      // 商品状态
      goodsStatusClick() {
        this.handleSearch()
      }
    }
  }

</script>
